<form id="authsaddfm" method="post" style="padding:0 8px 0 0;">
    <table border="0" width="100%" cellspacing="1" cellpadding="5" class="formtable">
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" width="10%">所属权限组：</td>
            <td width="90%">
                <select name="up" class="forminput inputstyle">
                    <option value=0>--根权限--</option>
                    <option disabled>----------</option>
                    <?php foreach($rootlevel as $v): ?>
                    <option value="<?php echo $v->id;?>"><?php echo $v->authname;?></option>
                    <?php endforeach; ?>
                </select>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">权限名称：</td>
            <td><input name="authname" type="text" style="width:400px;" class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox" placeholder="自定义权限名称.." required="true"></td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">控制器：</td>
            <td>
                <select name="controller" onchange="getAct(this.value);" class="forminput inputstyle">
                    <option value=''>--根权限不用选择控制器--</option>
                    <?php foreach($controllers as $v): ?>
                    <option value="<?php echo $v;?>"><?php echo $v;?></option>
                    <?php endforeach; ?>
                </select>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">方法：</td>
            <td>
                <div id="action"></div>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel" width="20%">排序：</td>
            <td>
                <input type="text" name="sortorder" value="500" class="forminput inputstyle"/>
            </td>
        </tr>
		<tr>
			<td colspan="2" bgcolor="#F4F4F4" style="border-top:#ddd 1px solid;text-align:right; padding-right:25px;">
				<div>
					<a href="javascript:;" class="l-btn l-btn-small" onclick="authsaddsubmit()"><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">保存</span><span class="l-btn-icon icon-ok">&nbsp;</span></span></a>
					<a href="javascript:;" class="l-btn l-btn-small" onclick="authsaddclearForm()"><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">关闭</span><span class="l-btn-icon icon-no">&nbsp;</span></span></a>
				</div>
			</td>
		</tr>
    </table>
</form>

<script>
    var getAct = function (ctl) {
        $.get('/admin/system/getacts?controller=' + ctl, function (data) {
            var act = '';
            $.each(data.data, function (key, value) {
                act += "<label style='width:160px;float:left;display:block;font-weight:100;'><input type='checkbox' name='action[]' value='" + value + "'>" + value + "</label>";
            });
            $('#action').html(act);
        }, 'json');
    };
	var authsaddclearForm = function () {
		$('#newsaddfm').form('clear');
		$('#rightTabs').tabs('close', '权限添加');
	};
    $(function () {
        $('#authsaddsubmit').click(function (data) {
            $('#authsaddfm').form('submit', {
                url: '/admin/system/authsInsert',
                success: function (data) {
                    var data = eval('(' + data + ')');

                    if (data.code == '200') {
                        $.messager.show({
                            title: '提示',
                            msg: data.msg,
                            timeout: 3000,
                            showType: 'slide'
                        });
                        $('#authsaddfm').form('clear');
                        $("#auths").treegrid('reload');
                    } else {
                        $.messager.alert('提示', data.msg, 'warning');
                    }
                }
            });
        });
    });
</script>







